#include "MyEventLoopThreadPool.h"

MyEventLoopThreadPool::MyEventLoopThreadPool()
    :_threadNum(4)
    ,_nextID(0)
{

}

MyEventLoopThreadPool::~MyEventLoopThreadPool()
{
    for(int i = 0; i < _threads.size(); ++i)
    {
        delete _threads[i];
    }
}

MyEventLoopThreadPool::MyEventLoopThreadPool(const int threadNum)
    :_threadNum(threadNum)
    ,_nextID(0)
{
    for(int i = 0; i < _threadNum; ++i)
    {
        MyEventLoopThread *thread = new MyEventLoopThread();
        _threads.push_back(thread);
    }
}

 MyEventLoopThread* MyEventLoopThreadPool::getNextThread()
 {
     if(_nextID >= _threadNum)
          _nextID = 0;
      return _threads[_nextID++];
 }
